Uploaded image for project: 'Maven Compiler Plugin'
  1. Maven Compiler Plugin
  2. MCOMPILER-550

Make 'outputDirectory' writable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.12.0
    • None

    Description

      Description of Improvement

      Currently, the property 'outputDirectory' is not writable, i.e. not meant to be modified.
      However, making it writable has at least two major advantages.

      Use case one – variable is already used

      Some Tutorials (e.g. https://www.baeldung.com/maven-multi-release-jars) already make use of rewriting the variable.

      Use case two: MR-Jars with different bytecode level.

      Another use case is Multi-Release-Jars. Currently, they can officially only be controlled by setting the release property. That will not only require a suitable JDK or Toolchain-JDK, it will also require the bytecode for that version to be the bytecode of that version.
      E.g. using release and multiReleaseOutput, the bytecode in META-INF/version/java9 MUST be exactly Java 9 bytecode.

      However, the JDK does not know of such restrictions.

      Using outputDirectory, you can now create Java 8 bytecode to run in e.g. Java 24. Here is an example use case: https://github.com/groovy/GMavenPlus/pull/287

      Granted, this could also be done differently, but this way it seems a little more elegant.
      The actual advantage is, that some developers can now plan ahead. For example, the SecurityManager is not just deprecated, it is deprecated for removal. The moment we know which Java version it is, we can create a MR-Jar for e.g. Java 30, even though Java 30 SDKs are not available then (currently we have Java 21 GA).

      Proposed solution

      Make variable writable as suggested in Slack.

      PR available locally.

      Attachments

        Issue Links

          Activity

            People

              bmarwell Benjamin Marwell
              bmarwell Benjamin Marwell
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: